Refactor PR/BEP README tables: split combined cells into sortable columns + fix counting of authors - #16
Open
yarikoptic wants to merge 2 commits into
Open
Refactor PR/BEP README tables: split combined cells into sortable columns + fix counting of authors#16yarikoptic wants to merge 2 commits into
yarikoptic wants to merge 2 commits into
Conversation
…view components Three changes to the generated `PRs/README.md` / `BEPs/README.md` tables: 1. Counts and dates now live in separate columns. `47 (2020-01-16 → 2026-05-08)` was a single cell, so GitHub's column sort ordered it as a string — useless for every ordering one actually wants. It is now `Comments` / `First comment` / `Last comment`, and the old `Commit window` cell is `Commits` / `First commit` / `Last commit` (the commit count was not previously surfaced at all). 2. `format_reviews` omits zero-valued components: `1✅/0❌/27💬` renders as `1✅/27💬`. All-zero still renders as `0`. 3. New `Created` column (PR open date, from the already-collected `stats.pr_created_at`). This explains the otherwise baffling rows where the first comment predates the first commit: on a long-lived PR a force-push replaces the branch's commits, and GitHub only reports what survived. PR #105 is the live example — opened 2018-12-12, earliest surviving commit authored 2022-04-22. Nothing recoverable sits in the commit metadata for those lost commits (the collector already prefers `authoredDate` over `committedDate`, which is what survives a plain rebase), so the fix is to show the PR's real start date alongside. Both READMEs gained a note saying so. The PR table's existing `Last commit` column (the built SHA) is renamed `Head` to free the name for the commit-window date. `format_stats_cells` now returns the keys in `STATS_CELL_KEYS`; `format_activity_span` and `format_date_window` are dropped as their only callers are gone. Tests updated and extended: review-component dropping, `format_count`, header/column-order lock, and a PR #105 regression guard.
`authors_count` was wrong in two independent ways, which is why BEP032 /
PR #2307 showed 2 contributors.
**Stale.** It is `git shortlog -sn | wc -l` run once when the *schema* is
built, and nothing ever refreshes it. PR #2307's value was recorded on
2026-05-12 at commit f6b65e5f, when the branch genuinely had two authors;
the branch has since grown to 24 commits and five people, but no schema
rebuild means no recount. Every other number in that row is refreshed
twice daily by `collect prs`, so the column silently disagreed with its
neighbours.
**Miscounted even when fresh.** `git shortlog` reads only the author
field and groups by display name. On PR #2307 that both misses the people
who merely landed patches and splits "Chris Markiewicz" /
"Christopher J. Markiewicz" — one address, markiewicz@stanford.edu — into
two contributors. Fresh shortlog gives 6; the real count is 5.
So contributor counting moves into the stats collector, where it is
recomputed every cycle:
- The commits GraphQL query now fetches `author`/`committer` as
`{name, email, user{login}}` rather than just the author's login.
- New `resolve_contributors()` derives `stats.contributors`
`{count, authors, committers, by_identity}`. Both roles count. Identity
is keyed on GitHub login when GitHub resolved the commit email to an
account and on the lowercased email otherwise, and a second pass folds
bare-email identities into a login when another commit tied that
address to an account — so one person split across resolved and
unresolved commits still counts once. GitHub's web-flow identity
(`noreply@github.com`) and `[bot]` logins are dropped; per-user
`…@users.noreply.github.com` addresses are real people and kept.
`tools/inject-schema-pr` still writes `authors_count` at build time, but
via a new `count_contributors` helper using mailmap-canonical `%aE`/`%cE`
rather than shortlog, so the seed is right too (5 for PR #2307). It is
now explicitly a seed: `format_contributors` prefers
`stats.contributors.count` and falls back to it only when stats are
absent.
Columns: `Authors` is renamed `# Authors` and a `# Commenters` column is
added, counting distinct accounts in `stats.comments.by_author`.
Note that `# Authors` keeps rendering the old seed value until the next
`collect prs` cycle populates `stats.contributors` — the collector needs
an authenticated `gh`, which this checkout has no access to.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Original PR was in my fork
which would have all the gory AI sloppy descriptions